<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		 <meta name="renderer" content="webkit">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>客服客户详情</title>
	</head>
	<link rel="stylesheet" href="/Public/frame/layui/css/layui.css">
	<!--<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">-->
	<link rel="stylesheet" href="/Public/frame/static/css/style.css">
	<body>		
    	
		
		<div class="layui-tab">
		  <ul class="layui-tab-title">
		    <li>客户基本信息</li>
		    <li>客户持仓情况</li>
		    <li class="layui-this">客户服务沟通情况</li>
		  </ul>
		  <div class="layui-tab-content">
		  	<!--1-->
		  	<div class="layui-tab-item">
		  	<form class="layui-form" action="<?php echo U('Customer/edit')?>" method="post">
				<input type="hidden" name="id" value="<?php echo $cus['info']['id'];?>">
				<input type="hidden" name="src" value="Service/moreInfo">
		  		<div class="layui-form-item">
		  			<label class="layui-form-label">客户姓名</label>
		  			<div class="layui-input-inline">
		  			<input type="text" name="cusname" lay-verify="required" placeholder="请输入客户姓名" autocomplete="off" class="layui-input" value="<?php echo $cus['info']['cusname'];?>">
		  			</div>

		  			<label class="layui-form-label">联系电话</label>
		  			<div class="layui-input-inline">
		  				<input type="text" name="tel" lay-verify="required" placeholder="请输入联系电话" autocomplete="off" class="layui-input" value="<?php echo $cus['info']['tel'];?>">
		  			</div>
		  		</div>
		  		<div class="layui-form-item">
		  			<label class="layui-form-label">地址</label>
		  			<div class="layui-input-block">
		  				<input type="text" name="address" lay-verify="title" autocomplete="off" placeholder="请输入地址" class="layui-input" value="<?php echo $cus['info']['address']==''?'无':$cus['info']['address'];?>">
		  			</div>
		  			<div class="layui-form-item" style="margin-top: 20px;">
		  				<label class="layui-form-label">身份证号码</label>
		  				<div class="layui-input-inline">
		  					<input type="text" name="ID_number" lay-verify="identity" placeholder="" disabled  autocomplete="off" class="layui-input" value="<?php echo $cus['info']['id_number'];?>">
		  				</div>

		  				<label class="layui-form-label">微信</label>
			  			<div class="layui-input-inline">
			  				<input type="text" name="wechat" lay-verify=""  autocomplete="off" class="layui-input" value="<?php echo $cus['info']['wechat'];?>">
			  			</div>
		  			</div>
		  			<div class="layui-form-item" pane="">
		  				<label class="layui-form-label">性别</label>
		  				<div class="layui-input-inline">
		  					<input type="text" name="sex" autocomplete="off" class="layui-input" value="<?php echo $cus['info']['sex']=='男'? '男':'女'?>">
		  				</div>

		  				<label class="layui-form-label">年龄</label>
		  				<div class="layui-input-inline">
		  					<input type="text" name="age" lay-verify="required"  placeholder="请输入客户年龄" autocomplete="off" class="layui-input" value="<?php echo $cus['info']['age'];?>">
		  				</div>
		  			</div>
		  			<div class="layui-form-item">
		  				<div class="layui-inline">
					        <label class="layui-form-label">产品名称</label>
					        <div class="layui-input-inline">
					        	<input type="text" name="product_name" lay-verify="required" autocomplete="off" class="layui-input" value="<?php echo $cus['info']['product_name'];?>">
					        </div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label">资源来源</label>
					    	<div class="layui-input-inline">
					    		<select name="resource" lay-filter="aihao">
					    			<option value="">请选择</option>
					    			<?php foreach ($cus['rtype'] as $k => $v): if ($v['name']==$cus['info']['resource']) $select = 'selected="selected"'; else $select = ''; ?>
					    				<option <?php echo ($select); ?> value="<?php echo ($v['name']); ?>"><?php echo ($v['name']); ?></option>
					    			<?php endforeach;?>
					    		</select>
					    	</div>
					    </div>
		  			</div>
		  			<div class="layui-form-item">
		  				<div class="layui-inline">
		  					<label class="layui-form-label">服务时间</label>
		  					<div class="layui-input-inline" style="width: 100px;">
		  						<input type="text" name="server_time_start" lay-verify="required" id="date2"  autocomplete="off" class="layui-input" value="<?php echo $cus['info']['server_time_start'];?>">
		  					</div>
		  					<div class="layui-form-mid">-</div>
		  					<div class="layui-input-inline" style="width: 100px;">
		  						<input type="text" name="server_time_end" lay-verify="required" id="date3"  autocomplete="off" class="layui-input" value="<?php echo $cus['info']['server_time_end'];?>">
		  					</div>
		  				</div>
		  				<div class="layui-inline">
					    <label class="layui-form-label">客户分类</label>
					    <div class="layui-input-block">
					      <select name="customer_type" lay-verify="required" lay-filter="aihao">
					        <option value="0">请选择</option>
<?php foreach ($type as $k => $v): if ($v['name']==$cus['info']['customer_type']) $select = 'selected="selected"'; else $select = ''; ?>
					        <option <?php echo ($select); ?> value="<?php echo ($v['name']); ?>"><?php echo ($v['name']); ?></option>
<?php endforeach;?>
					      </select>
					    </div>
				    </div>
		  			</div>
		  		</div>
		  		<div class="layui-form-item">
				    <div class="layui-input-block">
				      <button type="submit" class="layui-btn bbb" lay-submit="" lay-filter="demo1">立即提交</button>
				      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
				    </div>
				</div>
		  		</form>
		  	</div>
		  	<!--2-->
		    <div class="layui-tab-item">
		       <table class="layui-table" border="" cellspacing="" cellpadding="" width="100%">
		    		<thead>
		    			<tr>
		    				<td width="10%">股票代码</td>
		    				<td width="10%">股票名称</td>
		    				<td width="15%">成本价格(单位/元)</td>
		    				<td width="15%">现价(单位/元)</td>
		    				<td width="15%">持仓数量</td>
		    				<td width="10%">盈利(单位/元)</td>
		    				<td width="10%">来源</td>
		    				<td width="10%">详情</td>
		    			</tr>
		    		</thead>
		            <tbody>
		            <?php foreach ($cus['position'] as $k => $v):?>
		            	<tr>
		            		<td><?php echo ($v['stock_code']); ?></td>
		            		<td><?php echo ($v['stock_name']); ?></td>
		            		<td><?php echo ($v['sale_price']); ?></td>
		            		<td><?php echo ($v['price']); ?></td>
		            		<td><?php echo ($v['position_num']); ?></td>
		            		<td><?php echo ($v['price']-$v['sale_price'])*$v['position_num'];?></td>
		            		<td><?php echo ($v['source']); ?></td>
		            		<td><a href="<?php echo U('Position/lst?stock_code='.$v['stock_code'].'&cus_id='.$v['cus_id']); ?>" class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del" uid="<?php echo $v['id'];?>">详情</a></td>
		            	</tr>
		     		<?php endforeach;?>
		            </tbody>
		    	</table>
		    	<!-- <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		          	<legend style="font-size: 14px;">客户持仓统计</legend>
		        </fieldset> -->
		    	<table class="layui-table" border="" cellspacing="" cellpadding="" width="100%">
		    		<thead>
		    			<tr>
		    				<td width="25%">总资金量(元)</td>
		    				<td width="25%">持仓市值(元)</td>
		    				<td width="25%">剩余资金量(元)</td>
		    				<td width="25%">持仓比例</td>
		    			</tr>
		    		</thead>
		            <tbody>
		            	<tr id="count">
		            		<td><input type="number" id="total" cus_id ="<?php echo ($cus['info']['id']); ?>" value="<?php echo ($cus['info']['financing']); ?>"></td>
		            		<td><?php echo ($cus['market']); ?></td>
		            		<td><?php echo $cus['info']['financing']-$cus['market'];?></td>
		            		<td><?php echo $cus['market']/$cus['info']['financing']?></td>
		            	</tr>
		     
		            </tbody>
		    	</table>
		    </div>
		    <!--3-->
		    <div class="layui-tab-item layui-show">
		    	<table class="layui-table" border="" cellspacing="" cellpadding="" width="100%">
		    		<thead>
		    			<tr>
		    				<td width="10%">序号</td>
		    				<td width="30%">时间</td>
		    				<td width="60%">沟通记录</td>
		    			</tr>
		    		</thead>
		            <tbody>
		            <?php foreach ($cus['communicate'] as $k => $v):?>
		            	<tr>
		            		<td>1</td>
		            		<td><?php echo date('Y-m-d H:i:s',$v['addtime']); ?></td>
		            		<td><?php echo htmlspecialchars_decode($v['content']);?></td>
		            	</tr>
		     		<?php endforeach;?>
		     		<?php if(preg_match('/\d/', $cus['page'])): ?>  
					        <tr><td align="right" nowrap="true" colspan="99" height="30" class="page"><?php echo $cus['page']; ?></td></tr> 
					<?php endif; ?> 
		            </tbody>
		    	</table>
		    </div>		    
		  </div>
		</div>			
	</body>
	<script type="text/javascript" src="/Public/hawk/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="/Public/frame/layui/layui.js"></script>
	<script>
	layui.use(['element','jquery','form','layedit','layer','laydate'], function(){
	  var element = layui.element //Tab的切换功能，切换事件监听等，需要依赖element模块	
	  ,$ = layui.jquery
	  ,form = layui.form
	  ,layedit = layui.layedit
	  ,layer =layui.layer
	  ,laydate = layui.laydate;  	  
	});
	//ajax修改资金总量
	$('#total').on('blur',function(){
	  	var $this=$(this);
	  	var money = $(this).val();
	  	var cus_id = $(this).attr('cus_id');
	  	console.log(money);
	  	var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
	  	if (!reg.test(money)) {
          //layer.tips('请填写正确资金格式（1.00）', '#total');
          alert('请填写正确资金格式（1.00）');
          return false;
     	}
     	$.post('/index.php/Hawk/Service/ajaxMoney',{'financing':money,'cus_id':cus_id},function(data){
     		var obj = eval('('+data+')');
     		if(obj.code==1){
     			var total = $('#count').find('td').eq(0).find('input').val();
     			var all =$('#count').find('td').eq(1).text();
     			var liu = total-all;
     			var bi = all/total;
     			$('#count').find('td').eq(2).html(liu);
     			$('#count').find('td').eq(3).html(bi);
     			alert(obj.msg);
     			return false;
     		}else if(obj.code==0){
     			alert(obj.msg);
     		}
     	});
	});
	
	
	
	
</script>
</html>